<template>
	<view class="body">
		<myHeader :title="title"></myHeader>
		<view class="header">
			<view>
				<uni-search-bar @confirm="input()"
				  v-model="param.param.meetingName"
				   @clear="param.param.meetingName=''"
				   @cancel="cancel">
				</uni-search-bar>
			</view>
		</view>
		<view class="main">

			<view class="content">
				<!-- 按钮 -->
				<uni-fab horizontal="right" vertical="bottom" direction="vertical"
					:popMenu="true" @fabClick="fabClick" :pattern="pattern">
				</uni-fab>
				<!-- 滑块内容 -->
				<scroll-view scroll-y="true" class="scroll-Y" style="height: 400px;">
					<image v-if="loadData.length===0" 
					 src="../../static/party_building/assets/nothing.png" mode="">
					</image>
					<uni-collapse>
					    <uni-collapse-item   v-for="(item,key) in loadData" :title="item.title" >
					        <view style="padding: 30rpx;">
					          <uni-card :title="item.meetingTheme" :note="item.meetingRoom" :is-shadow="true"
					          	:extra="item.extra">
					          	<!-- <template v-slot:footer> -->
					          	<template solt="footer">
					          		<view class="footer-box">
					          			<uni-steps activeColor="#e20909" :options="item.pop" direction="column"
					          				:active="item.active"></uni-steps>
												<button type="default" class="mybutton" @click="gotoDetail(item,false)" size="mini">预览详情</button>
												<!-- 	<button type="default" v-if="item.redata.meetingStatus==='2'" class="mybutton" @click="huizong(item.redata.meetingId)" size="mini">汇总文档</button> -->
									</view>
					          	</template>
					          </uni-card>
					        </view>
					    </uni-collapse-item>
					</uni-collapse>
					
					<!-- 加载更多 -->
					<uni-load-more
						 @clickLoadMore="clickLoadMore" 
						:status="loadMore" :showIcon="false"
						iconType="auto" 
						:contentText="{
						contentdown: '点击显示更多',
						contentrefresh: '正在加载...',
						contentnomore: '没有更多数据了'}">
					</uni-load-more>
				
				</scroll-view>
				
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import myHeader from '../components/head.vue'
	import {
		getGroupUser,
		addMeetingByGroup,
		checkMeetingByLeader,
		getMeetingByGroup,
		getMeetingByLeader,collectMeeting
	}
	from '../../api/api_party_meeting.js'
	export default {
		data() {
			return {
				title: "质量监督小组",
				search: '',
				loadMore:'',
				param://[组长0：监督小组 1：质量小组 2：安全小组]
					{
						"current": 1,
						"pageSize": 10,
						"total":0,
						"param": {
							"meetingName": "",
							"status": "1"
						}
					},
				loadData: [ 
				// 	{//data是最终展示数据
				// 	address: "2020-05-12——2020-05-20",
				// 	extra: "未完成",
				// 	title: "办公司清洁打扫",
				// 	pop: [{
				// 			title: '组长发起会议',
				// 			desc: '2018-11-11'
				// 		},
				// 		{
				// 			title: '会议通过',
				// 			desc: '2018-11-11'
				// 		},
				// 		{
				// 			title: '执行任务',
				// 			desc: '2018-11-12'
				// 		},
				// 		{
				// 			title: '监督任务',
				// 			desc: '2018-11-13'
				// 		},
				// 		{
				// 			title: '监督评审',
				// 			desc: '2018-11-14'
				// 		}
				// 	],
				// 	active: 2,
				// }, 
				],
				pattern: {//按钮样式
					color: "#FFF",
					selectedColor: "#007AFF",
					backgroundColor: "#2096f3",
					buttonColor: "#e20909"
				},
			}
		},
		components: {
			myHeader
		},
		onShow() {
			this.clickLoadMore();
		},
		methods: {
			sreachIt: function() { //键盘输入
				uni.showToast({
					title: this.search,
					duration: 1000
				})
			},
			huizong(meetingId){
				collectMeeting({
					meetingId
				}).then(res=>{
					uni.downloadFile({
						url:res,
						success: () => {
							uni.showToast({
								title:'下载成功！请在文件中查看',
								duration:2000,
							})
						},fail: () => {
							uni.showToast({
								title:'下载失败',
								duration:2000,
								icon:'none'
							})
						}
					})
				})},
			onClickItem(ars) {
				this.current = ars.currentIndex
			},
			fabClick() { //悬浮按钮点击
				/**
				 * 安全领导小组固定id = 4
				 * 质量监督小组固定id = 5
				 * 监督小组固定id = 6
				 */
				uni.navigateTo({
					url: "./addmeeting?roleCode=5"
				})

			},
			submitForm() {
				let _this = this;
				this.$refs.form.submit().then((res) => {
					// _this. 
					console.log('表单返回得值：', res)
				})
			},
			clickLoadMore(){//待处理会议
				this.loadMore = 'loading'
				let _this = this;
					getMeetingByGroup(
					_this.param
					).then(res =>{
						_this.loadMore = 'more'
						if(res.total<_this.param.pageSize){
							 _this.loadMore = 'noMore'
						}
					//处理过程
					let data = []
					
					res.records.forEach(item =>{
						let extra = item.meetingStatus==='1'?"会议文件待审核":item.meetingStatus==='2'?"任务进行中":item.meetingStatus==='3'?"文件已汇总":"未知状态"
						let admin = item.judgeUser===null?"党支部负责人":item.judgeUser+' '+item.updateTime
						let updateTime = item.updateTime===null?'暂无':item.updateTime
						let endTime = item.endTime===null?'暂无':item.endTime
						data.push({//data是最终展示数据
							address:"来源："+item.meetGroup,
							extra,
							title: item.meetingName,
							createUser:item.createUser,
							pop: [{
									title: '组长发起会议',
									desc: item.createTime
								},
								{
									title: '会议通过',
									desc: admin
								},
								{
									title: '汇总文件',
									desc: endTime
								},
							],
							active:item.meetingStatus-1,//步骤
							redata:item,
						})
					})
					_this.param.current++;
					_this.loadData = _this.loadData.concat(data)
					// _this.param.pageSize = res.size
					// _this.param.total = res.total
					})
			},
			cancel(){//搜索框取消
				this.param={
						"current": 1,
						"pageSize": 10,
						"param": {
							"meetingName": "",
							"status": "1"
						}
					},
					this.loadData= [];
				this.clickLoadMore()
			},
			gotoDetail(ars){
					console.log(ars.redata)
					uni.navigateTo({
						url:`./meettingdetails/templateDetails?meetingId=${ars.redata.meetingId}`
					})
			},
			input(){//input点击
					this.param.current = 1,
					this.pageSize = 100,
					this.loadData= [];
				this.clickLoadMore()
			}
		}
	}
</script>

<style lang="scss" scoped>
		/**
		 * 定义按钮样式
		 */
		@mixin button-commit {
			background: linear-gradient(180deg, #ff5e59, #e20909);
			color: #fff;
		}
	.body {
		background-color: #f7f7f7;
		height: 100%;
		.mybutton{
				@include button-commit;
				margin-top: 5%;
		}
	}

	.header {
		background-color: #fff;
		/deep/ .uni-searchbar {
			width: 100%;
			margin: 0 auto 0 auto;
		}
	}
	.main {
		background-color: #fff;
		width: 95%;
		margin: 5% auto 0 auto;
		height: 65%;
		.content {
			/deep/ .uni-transition {
			}
			/deep/ .uni-card{
				margin: 0;
			}
		}
	}
</style>
